﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Demo.Lib;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using Demo.Impl;

namespace UnityStrategy {
    class Program {
        static void Main(string[] args) {
            string strategyName = args[0];
            IConversionMappingStrategy strategy = CreateStrategy(strategyName); 
            
            ChineseConverter converter = new ChineseConverter();

            using (var input = File.OpenRead(args[1])) {
                converter.Convert(input, args[2], strategy);
            }

        }


        static IConversionMappingStrategy CreateStrategy(string strategyName) {
            if (strategyName == "s") {
                return new ToSimplifyStrategy();
            }
            else if (strategyName == "r") {
                return new RomanizationStrategy();
            }
            else {
                return new ToTraditionalStrategy();
            }
        }

        static IConversionMappingStrategy ResolveStrategy(string strategyName) {
            UnityContainer container = new UnityContainer();
            container.LoadConfiguration();
            return container.Resolve<IConversionMappingStrategy>(strategyName);
        }

    }
}